Micron Document
`:top
In `F33f`_`[computer programming`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computer_programming]`_`f, a `!nullary constructor`! is a `F33f`_`[constructor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Constructor_(computer_science)]`_`f that takes no `F33f`_`[arguments`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Parameter_(computer_science)]`_`f.`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f] Also known as a `!0-argument constructor`!, `!no-argument constructor`!,`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f] `!parameterless constructor`! or `!default constructor`!.`:cite-ref-3[`F5bf`_`[3`#cite-note-3]`_`f]

>>Contents

• `F0af`_`[Object-oriented constructors`#object-oriented-constructors]`_`f
• `F0af`_`[Java example`#java-example]`_`f
• `F0af`_`[Algebraic data types`#algebraic-data-types]`_`f
• `F0af`_`[Haskell example`#haskell-example]`_`f
• `F0af`_`[References`#references]`_`f

-─

>>Object-oriented constructors

In `F33f`_`[object-oriented programming`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Object-oriented_programming]`_`f, a `F33f`_`[constructor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Constructor_(computer_science)]`_`f is code that is run when an `F33f`_`[object`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Object_(computer_science)]`_`f is created. `F33f`_`[Default constructors`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Default_constructor]`_`f of objects are usually nullary.`:cite-ref-4[`F5bf`_`[4`#cite-note-4]`_`f]

>>>Java example

`B100`F9d9public class Example`f`b
`B100`F9d9{`f`b
`B100`F9d9 protected int data;`f`b
`B100`F9d9`f`b
`B100`F9d9 /* Nullary constructor */`f`b
`B100`F9d9 public Example()`f`b
`B100`F9d9 {`f`b
`B100`F9d9 this(0);`f`b
`B100`F9d9 }`f`b
`B100`F9d9`f`b
`B100`F9d9 /* Non-nullary constructor */`f`b
`B100`F9d9 public Example(final int data)`f`b
`B100`F9d9 {`f`b
`B100`F9d9 this.data = data;`f`b
`B100`F9d9 }`f`b
`B100`F9d9}`f`b

>>Algebraic data types

In `F33f`_`[algebraic data types`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Algebraic_data_types]`_`f, a constructor is one of many tags that wrap data. If a constructor does not take any data arguments, it is nullary.

>>>Haskell example

`B100`F9d9-- nullary type constructor with two nullary data constructors`f`b
`B100`F9d9data Bool = False`f`b
`B100`F9d9 | True`f`b
`B100`F9d9`f`b
`B100`F9d9-- non-nullary type constructor with one non-nullary data constructor`f`b
`B100`F9d9data Point a = Point a a`f`b
`B100`F9d9`f`b
`B100`F9d9-- non-nullary type constructor with...`f`b
`B100`F9d9data Maybe a = Nothing -- ...nullary data constructor`f`b
`B100`F9d9 | Just a -- ...unary data constructor`f`b

>>References

`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f "Default Constructor in Java – Class Constructor Example". `*freeCodeCamp.org`*. 2022-01-13. Retrieved 2022-03-23.
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f "No-argument Constructor". `*chortle.ccsu.edu`*. Retrieved 2022-03-23.
`:cite-note-3`!3.`! `F0af`_`[↑`#cite-ref-3]`_`f "Default constructors - cppreference.com". `*en.cppreference.com`*. Retrieved 2023-04-12.
`:cite-note-4`!4.`! `F0af`_`[↑`#cite-ref-4]`_`f `:citerefottingerlinwoodminter2022`aOttinger, Joseph B.; Linwood, Jeff; Minter, Dave (2022), Ottinger, Joseph B.; Linwood, Jeff; Minter, Dave (eds.), "An Introduction to Hibernate 6", `*Beginning Hibernate 6: Java Persistence from Beginner to Pro`*, Berkeley, CA: Apress, pp. 1–25, `F33f`_`[doi`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Doi_(identifier)]`_`f:10.1007/978-1-4842-7337-1_1, `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 978-1-4842-7337-1, retrieved 2022-03-23

`c`F0af`_`[↑ Back to top`#top]`_`f`a